package cc.sbootd2.sbootd2web.service.impl;

import org.springframework.stereotype.Service;
import cc.sbootd2.sbootd2web.dao.NewsTypeMapper;
import cc.sbootd2.sbootd2web.pojo.NewsType;
import cc.sbootd2.sbootd2web.service.NewsTypeService;

import javax.annotation.Resource;
import java.util.List;


@Service("newsTypeService")
public class NewsTypeServiceImpl implements NewsTypeService {

    @Resource
    private NewsTypeMapper newsTypeMapper;



    @Override
    public int save(NewsType newsType) {
        if(newsType.getParentId()==0){
            newsType.setParentId(null);
        }
        return newsTypeMapper.save(newsType);
    }

    @Override
    public int delete(Integer id) {
        return newsTypeMapper.delete(id);
    }

    @Override
    public int update(NewsType newsType) {
        return newsTypeMapper.update(newsType);
    }

    @Override
    public NewsType getNewsTypeById(Integer id) {
        return newsTypeMapper.getNewsTypeById(id);
    }

    @Override
    public List<NewsType> getAllNewsType() {
        return newsTypeMapper.getAllNewsType();
    }

    @Override
    public List<NewsType> getTopNewsType() {
        return newsTypeMapper.getTopNewsType();
    }

    @Override
    public List<NewsType> getNewsTypeByPage(NewsType newsType) {

        return newsTypeMapper.getNewsTypeByPage(newsType);
    }

    @Override
    public int getRecordCount(NewsType newsType) {

        return newsTypeMapper.getRecordCount(newsType);
    }

    @Override
    public int getChildNewsTypeCount(int parentId) {
        return newsTypeMapper.getChildNewsTypeCount(parentId);
    }

    @Override
    public int deleteAll(List<Integer> ids) {
        return newsTypeMapper.deleteAll(ids);
    }

    @Override
    public int getChildNewsTypeCountByIds(List<Integer> ids) {
        return newsTypeMapper.getChildNewsTypeCountByIds(ids);
    }


}
